package com.zqa.ocr.config;

import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import com.tencentcloudapi.ocr.v20181119.OcrClient;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Getter
@Setter
@Slf4j
@Configuration
@ConfigurationProperties(prefix = "tencent")
public class OCRConfig {

    private  String SecretId=null;

    private  String SecretKey=null;

    private  String Region=null;

    private  String OrcEndpoint=null;


    @Bean
    public OcrClient createOrcClient(){
        OcrClient client=null;
        try{
            Credential cred = new Credential(SecretId, SecretKey);

            HttpProfile httpProfile = new HttpProfile();
            httpProfile.setEndpoint(OrcEndpoint);

            ClientProfile clientProfile = new ClientProfile();
            clientProfile.setHttpProfile(httpProfile);

            client = new OcrClient(cred, Region, clientProfile);
        }catch (Exception e){
            log.error(e.getMessage());
        }

        return client;
    }




}
